// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vuex from 'vuex'
Vue.use(Vuex)
import store from './store/index.js'

//引用UI
import YDUI from 'vue-ydui'
Vue.use(YDUI)
import 'vue-ydui/dist/ydui.rem.css'
import 'vue-ydui/dist/ydui.flexible.js'
import 'vue-ydui/dist/ydui.base.css'
import {FlexBox, FlexBoxItem} from 'vue-ydui/dist/lib.rem/flexbox'

import ElementUI from 'element-ui'
Vue.use(ElementUI)
import 'element-ui/lib/theme-default/index.css'
//自定义
import './assets/css/index.css'
import './assets/js/global.js'
import common from './components/common'

// ui组件的按需引入
import { Popover } from 'element-ui'
Vue.use(Popover)
Vue.component(FlexBox.name, FlexBox);
Vue.component(FlexBoxItem.name, FlexBoxItem);

Vue.config.productionTip = false

Object.keys(common).forEach((key) => {
  console.log(key, common)
  var name = key.replace(/(\w)/, (v) => v.toUpperCase())
  Vue.component(`v${name}`, common[key])
})

// router.beforeEach((to, from, next) => {
//   if (token !== '') {
//     next(('/login'))
//     return
//   }
//   next()
// })

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
